package IOStream;

import java.io.*;

/*
    缓冲流
    使用缓冲流来完成文件的复制
 */
public class BufferedStreamDemo {
    public static void main(String[] args) {
        File file1=new File("c:\\Users\\Administrator\\Desktop\\jdk9-api.CHM");
        File file2=new File("c:\\IOStream\\javaAPI.CHM");
        BufferedInputStream bis= null;
        BufferedOutputStream bos=null;
        try {
            bis = new BufferedInputStream(new FileInputStream(file1));
            bos=new BufferedOutputStream(new FileOutputStream(file2));
            int a=-1;
            while ((a=bis.read())!=-1){
                bos.write(a);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bis.close();
                bos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
